package bookManager;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        User user = login();
        while(true){
            int choice = user.menu();
            user.doOperation(choice);

        }
    }

    private static User login() {
        Scanner scanner = new Scanner(System.in);

        System.out.println("请先输入您的用户名：");
        String username = scanner.next();
        System.out.println("请输入您的密码： ");
        String password = scanner.next();

        UserDao userDao = new UserDao();
        User user = userDao.findUserByName(username);

        if (user == null) {
            System.out.println("登录失败！");
            System.exit(0);
            //return null;
        }

        if (!user.getPassword().equals(password)) {
            System.out.println("登录失败！");
            System.exit(0);
        }
        return user;
    }
}
